package edu.nf.ch06.easy;

import edu.nf.ch06.product.IPhone;
import edu.nf.ch06.product.MiPhone;

/**
 * @author CSY
 * @date 2025 - 04 - 15
 * 简单工厂
 */
public class ObjectFactory {
    public Object create(String name){
        if ("iphone".equals(name)){
            return new IPhone();
        } else if ("xiaomi".equals(name)) {
            return new MiPhone();
        }else{
            throw new IllegalArgumentException("Unknown phone: " + name);
        }
    }

}
